package com.situ.controller;

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.situ.entily.Danju;
import com.situ.service.DanjuService;
import com.situ.service.impl.DanjuServiceImpl;
import com.situ.util.BaseController;
import com.situ.vo.DanjuVO;
import com.situ.vo.LayuiTableVO;
import com.situ.vo.ResultVO;

@WebServlet("/danju")
public class DanjuController extends BaseController{

	private static final long serialVersionUID = 1L;

	DanjuService service =new DanjuServiceImpl();
	
	public void page(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.getRequestDispatcher("/WEB-INF/danju.jsp").forward(request, response);
	}
	
	public LayuiTableVO list(Integer page, Integer limit, String keyword,Date keyword2) {
		List<DanjuVO> list = service.all(page, limit, keyword,keyword2);
		LayuiTableVO vo = new LayuiTableVO();
		vo.setCode(0);
		vo.setData(list);
		vo.setCount(service.count(keyword,keyword2));
		return vo;
	}
	
	public ResultVO save(Danju d, HttpSession session) {
		ResultVO vo=service.save(d,session);
		return vo;
	}
	
	public void delete(Integer id) {
		service.delete(id);
	}
	
	public DanjuVO sel(Integer id) {

		return service.selectById(id);

	}
}
